<?php



namespace app\bbxw\controller\api;



use app\bbxw\service\WechatService;
use app\bbxw\service\UserAdminService;
use think\admin\Controller;
use app\bbxw\model\WxUser as WxUserMod;
use think\admin\model\SystemUser;

/**
 * 登录接口
 * Class Login
 * @package app\data\controller\api
 */
class Login extends Controller
{
    // 用户登录接口
    public function customr()
    {
        $data = $this->request->post();
        $this->_vali([
            'name.require'    => '账号不能为空！',
            'password.require'    => '密码不能为空！',
        ],$data);
        $customer = $this->app->db->name("customer")->where(['name'=>$data['name']])->find();
        if(empty($customer)){
            $this->error("账号不存在");
        }else{
            if($customer['grade']<2){
                $this->error("只要黄金会员才能登录");
            }
            if($customer['password'] != md5($data['password'])){
                $this->error("密码错误");
            }else{
                $this->success('登录成功！', $customer);
            }
        }
    }

    //陪玩登录
    public function powersource()
    {
        $data = $this->request->post();
        $this->_vali([
            'name.require'    => '账号不能为空！',
            'password.require'    => '密码不能为空！',
        ],$data);
        $customer = $this->app->db->name("power_source")->where(['name'=>$data['name']])->whereOr('nickname',$data['name'])->find();
        if(empty($customer)){
            $this->error("账号不存在");
        }else{

            if($customer['password'] != md5($data['password'])){
                $this->error("密码错误");
            }else{
                $this->success('登录成功！', $customer);
            }
        }
    }

    public function getNotify()
    {
        $name = $this->request->get('name');
        $this->success('success！', sysconf($name));

    }

}
